# *-* coding: utf-8 *-*
"""
@author: Hekang Xu (E-mail:1092181938@qq.com)
"""


import os


def output_images(multi_files, out_path):
    """
    将图片输出
    :param multi_files:输入的所有文件路径
    :param out_path:输出的路径
    :return:输出成功结果
    """
    all_output_path = []
    for file in multi_files:
        if os.path.exists(file):
            output_file(file, out_path)
            all_output_path.append(out_path + "/" + os.path.basename(os.path.realpath(file)))
    return all_output_path


def output_file(file, out_path):
    out_path = out_path + "/" + os.path.basename(os.path.realpath(file))
    input = open(file, 'rb')
    output = open(out_path, 'wb')
    try:
        while True:
            chunk = input.read(100)
            if not chunk:
                break
            output.write(chunk)
    finally:
        input.close()
        output.close()
